<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正则表达式中的转义</title>
</head>
<body>
    <script>
        let hd = '123.456';
        // \d表示数字   \w表示字母数字下划线  +表示多个  \.表示.

        // 字面量形式
        console.log(/\d+\.\d+/.test(hd));

        // 对象形式,要先将字符串转换成字面量里的形式
        console.log('\\d+\\.\\d+');
        let reg = new RegExp('\\d+\\.\\d+','g');
        console.log(reg.test(hd));


        let url = "https://www.houdunren.com";
        console.log(/https?\:\/\/\w+\.\w+\.\w+/.test(url));
        console.log("https?\\:\\/\\/\\w+\\.\\w+\\.\\w+");
        let reg1 = new RegExp('https?\\:\\/\\/\\w+\\.\\w+\\.\\w+','g');
        console.log(reg1.test(url));

    </script>
</body>
</html>